//
//  SecondViewController.m
//  07-界面通信
//
//  Created by 402030900@qq.com on 16/7/22.
//  Copyright © 2016年 402030900@qq.com. All rights reserved.
//

#import "SecondViewController.h"

@interface SecondViewController ()
@property(nonatomic,strong)UITextField * tf;
@end

@implementation SecondViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //textField
    self.view.backgroundColor = [UIColor colorWithRed:0.583 green:1.000 blue:0.621 alpha:1.000];
    _tf = [[UITextField alloc]initWithFrame:CGRectMake(100, 100, 175, 50)];
    _tf.backgroundColor = [UIColor colorWithRed:1.000 green:0.428 blue:0.420 alpha:1.000];
    _tf.placeholder = @"这是一个文本框";
    _tf.text = _passString;
    [self.view addSubview:_tf];
    //button
    UIButton * button = [UIButton buttonWithType:(UIButtonTypeSystem)];
    [button setFrame:CGRectMake(100, 300, 100, 50)];
    [button setTitle:@"按钮" forState:(UIControlStateNormal)];
    [button addTarget:self action:@selector(clickButton:) forControlEvents:(UIControlEventTouchUpInside)];
    button.backgroundColor = [UIColor colorWithRed:1.000 green:0.512 blue:0.926 alpha:1.000];
    [self.view addSubview:button];
    // Do any additional setup after loading the view.
}
-(void)clickButton:(UIButton *)button{
#warning  传值
    if (self.delegate && [self.delegate respondsToSelector:@selector(passValue:)]) {
        [self.delegate passValue:_tf.text];
    }
    [self.delegate passValue:_tf.text];
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
